#include <stdio.h>
#include <string.h>
#define u16 unsigned short

typedef struct
{
    u16 High;
    u16 Low;
}PACK;
PACK buff[15] = {0};
u16 ReadData(u16 *input,int num)
{
    u16 tmp = 0u;
    int i;
    tmp = *input;
    for(i=0;i<(num-1);i++)
    {
        *(u16 *)(input + i) = *(u16 *)(input + i + 1);
    }
    *(input + num - 1) &= 0x0;
    return tmp;
}
void Trans(u16 *input,int num)
{
    unsigned char statusoe = 0u;
    unsigned char n = 0u;
    static unsigned char store = 0u;
    static u16 storenum = 0u;
    int i;
    
    memset(buff,0,sizeof(buff));

    n = num - store;
    statusoe = ((n%2)==1);
    n = (n - statusoe) / 2;
    if(store == 1)
    {
        buff[0].Low = storenum;
        buff[0].High = ReadData(input,num);
    }
    for(i=store;i<(n+store);i++)
    {
        buff[i].Low = ReadData(input,num);
        buff[i].High = ReadData(input,num);
    }
    if(statusoe == 1)
    {
        store = 1;
        storenum = ReadData(input,num);
    }
}
void print(PACK *input,int num)
{
    int i;
    for(i=0;i<num;i++)
    {
        if(((input+i)->Low == 0)&&((input+i)->High == 0))
        {
            return;
        }
        printf("[%d].Low = 0x%X,[%d].High = 0x%X\n",i,(input+i)->Low,i,(input+i)->High);
    }
    memset(buff,0,sizeof(buff));
}
int main(void)
{
    u16 a[3] = {0x1111,0x2222,0x3333};
    u16 b[4] = {0x1212,0x2323,0x3434,0x4545};
    u16 c[5] = {0x1010,0x2121,0x3131,0x4141,0x5151};

    Trans(a,sizeof(a)/2);
    print(buff,sizeof(buff));
    Trans(b,sizeof(b)/2);
    print(buff,sizeof(buff));
    Trans(c,sizeof(c)/2);
    print(buff,sizeof(buff));
        
}
